package com.mercenary.wein.screenControl.ui.batch;

import com.mercenary.wein.screenControl.bean.DeviceBean;
import com.mercenary.wein.screenControl.command.CommandTool;

import javax.swing.JDialog;
import javax.swing.JDialog;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.Border;


public class FriendPunctuatePraise extends JDialog {
    // Log log = LogFactory.getLog( FriendPunctuatePraise.class);
    JLabel label;
    GroupCheckBoxPanel RequestJ1 = new GroupCheckBoxPanel();//面板1
    JPanel RequestJ2 = new JPanel();//面板2
    static JFrame locationjf = new JFrame();
    JTextField num;

    public FriendPunctuatePraise() {
        super(locationjf, "点赞");
        setBounds(200, 100, 700, 550);
        setLayout(new BorderLayout());
        setVisible(true);
        add(RequestJ1, BorderLayout.WEST);
        add(RequestJ2, BorderLayout.EAST);
        RequestJ1.setPreferredSize(new Dimension(180, 550));//设置大小
        RequestJ2.setLayout(new FlowLayout(FlowLayout.LEADING, 500, 10));
        RequestJ1.setBackground(Color.WHITE);
        RequestJ2.setPreferredSize(new Dimension(480, 550));
        RequestJ2.setBackground(Color.WHITE);
        Border titleBorder1 = BorderFactory.createTitledBorder("点赞");// 设置面板边框，实现分组框的效果       .设置面板边框颜色
        RequestJ2.setBorder(titleBorder1);
        //J2中的组件
        FlowLayout layout = new FlowLayout(FlowLayout.LEADING);
        RequestJ2.setLayout(layout);
        JPanel jp1 = new JPanel(new FlowLayout(FlowLayout.LEADING));
        final ExeModeButtonGroup jp2 = new ExeModeButtonGroup(this);
        final JPanel jp3 = new JPanel(new FlowLayout(FlowLayout.LEADING));
        jp1.setPreferredSize(new Dimension(500, 30));//设置大小
        jp2.setPreferredSize(new Dimension(500, 120));//设置大小
        jp3.setPreferredSize(new Dimension(500, 40));//设置大小
        JLabel L1 = new JLabel("点赞次数:");
        final JTextField num = new JTextField();
        num.setPreferredSize(new Dimension(35, 25));
        jp1.add(L1);
        jp1.add(num);
        JButton submit = new JButton("提交任务");
        //这块我不会，感觉应该还缺通讯录的参数@涂笑
        //	submit.addActionListener(new SubmitListener(RequestJ1.getSelectedDevices(),int num));
        jp3.add(submit);
        RequestJ2.add(jp1);
        RequestJ2.add(jp2);
        RequestJ2.add(jp3);

        submit.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                CommandTool.thumb(RequestJ1.getSelectedDevices(),
                        num.getText().matches("\\d")?Integer.parseInt(num.getText()):1,jp2.getExeModeBean());
            }
        });


    }

    public static void main(String[] arge) {
        new FriendPunctuatePraise();


    }

}

class SubmitListener3 implements ActionListener {
    private List<DeviceBean> devices;
    private List<String> phoneNums;
    private int num;
    private int start;
    private int end;


    public void SubmitListener(List<DeviceBean> devices, List<String> phoneNums, AddModel addMode) {
        this.devices = devices;
        this.phoneNums = phoneNums;
        this.num = addMode.getNumber();
        this.start = addMode.getStart();
        this.end = addMode.getEnd();
    }

    public void actionPerformed(ActionEvent e) {
        //这儿新建一个类不对，应该是要获取当前对象，我不会@涂笑
        FriendPunctuatePraise a = new FriendPunctuatePraise();
        num = Integer.parseInt(a.num.getText());

        System.out.println(num);
//		CommandTool.AddAddressBookFriend(devices, phoneNums,  num,start,end);
    }
}

			


